define(['jquery', 'bootstrap', 'backend', 'table', 'form','layer'], function ($, undefined, Backend, Table, Form) {
    
  
    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'performance/admin/index',
                    add_url: 'performance/admin/add',
                    edit_url: 'performance/admin/edit',
                    del_url: 'performance/admin/del',
                    multi_url: 'performance/admin/multi',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                queryParams:function (params) {
                  
                    // var admin_id = '7';//
                    //自定义参数 ，固定参数不做修改
                     return {  
                        limit:params.limit,
                        search:params.search,
                        filter:params.filter,  
                        offset:params.offset,  
                        order:params.order,  
                        sort:params.sort,
                       
                        
                    };
                },
                columns: [
                    [
                        {field: 'state', checkbox: true, },
                        {field: 'id', title: 'ID'},
                        {field: 'username', title: __('Username')},
                        {field: 'nickname', title: __('Nickname')},
                        {field: 'groups_text', title: __('Group'), operate:false, formatter: Table.api.formatter.label},
                        {field: 'department_name', title:'部门', operate:false},
                        // {field: 'department_id', title:'部门'},
                        {field: 'department_id', title:'部门', class:"hidden",searchList: $.getJSON('performance/performance/getlist?name=department'), style: 'min-width:100px;'},
                        {field: 'groupname_id', title:'部门', class:"hidden",searchList: $.getJSON('performance/performance/getlist?name=groupname'), style: 'min-width:100px;'},
                        {field: 'groupname_name', title:'分组', operate:false},
                        {field: 'email', title: __('Email')},
                        // {field: 'status', title: __("Status"), formatter: Table.api.formatter.status},
                        {field: 'is_check_month', title: '状态', formatter: function(value,row,index){
                          
                            if(row.is_month_check == '1'){
                                return "<span class=\"need-check\">当月未评</span>";
                            }else{
                                return "<span class=\"no-need-check\">当月已评（"+row.content+"）</span>";;
                            }
                        }},
                        // {field: 'logintime', title: __('Login time'), formatter: Table.api.formatter.datetime},
                       
                        {field: 'id', title: '评分', table: table, formatter: function (value, row, index) {
                               
                                var url = 'performance/performance?admin_id='+row.id;
                            
                                return "<a href="+url+" addtabs=\"158\" class=\"btn-addtabs\" data-title=\"自评\">评分</a>";
                            }
                        }
                    ]
                ],
                onLoadSuccess:function(){
                    $(".btn-dialog-in").click(function(){
                        perContent = layer.open({
                         
                            maxmin: true,            //最大化按钮
                         
                            // shade: [0.8, '#393D49'],//遮罩层
                            // end: function(){
                                
                            // }
                        });
                        layer.full(perContent);
                    })
                    
                }
            });

            // 为表格绑定事件
            Table.api.bindevent(table);

        },
        add: function () {
            Form.api.bindevent($("form[role=form]"));
        },
        edit: function () {
            Form.api.bindevent($("form[role=form]"));
        }
    };
    return Controller;
});